<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page isELIgnored="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta charset="utf-8">
    <title>用户主页</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/resource/layui/css/layui.css">
    <link rel="stylesheet" href="/resource/css/global.css">
</head>
<body style="margin-top: 65px;">

<div class="fly-header layui-bg-green">
    <div class="layui-container">
        <a class="fly-logo" href="/user/redirectIndex.do">
            <div class="layui-logo" style="font-size: 20px; color: #CAE1FF;"><span class="iconfont-ali icon-B" style="font-size: 35px"></span></div>
        </a>
        <ul class="layui-nav fly-nav layui-hide-xs">
            <li class="layui-nav-item layui-this">
                <a href="/user/redirectIndex.do"><i class="layui-icon  layui-icon-home"></i>首页</a>
            </li>
        </ul>
        <ul class="layui-nav fly-nav-user">
            <!-- 未登入的状态 -->
            <c:if test="${user==null }">
                <li class="layui-nav-item"><a
                        class="iconfont-ali icon-yonghu layui-hide-xs" href="user/login.html"></a>
                </li>
                <li class="layui-nav-item"><a href="/login.html">登入</a></li>
                <li class="layui-nav-item"><a href="/register.html">注册</a></li>
            </c:if>
            <!-- 登入后的状态 -->
            <c:if test="${user!=null }">
                <li class="layui-nav-item"><a class="fly-nav-avatar"
                                              href="javascript:;"> <cite class="layui-hide-xs">${user.userName }</cite>
                    <img
                            <c:if test="${!empty user.headSculpture }">src="${user.headSculpture }" </c:if>
                        <c:if test="${empty user.headSculpture }">src="/resource/img/logo.JPG"</c:if>
                            alt="${user.userName}">
                </a>
                    <dl class="layui-nav-child layui-bg-green">
                        <dd><a href="/user/userindex.do"><i class="layui-icon">&#xe609;</i>用户中心</a></dd>
                        <dd>
                            <a href="/user/userset.do"><i class="layui-icon">&#xe620;</i>基本设置</a>
                        </dd>
                        <dd>
                            <a href="/user/usermessage.do"><i class="iconfont icon-tongzhi" style="top: 4px;"></i>我的消息</a>
                        </dd>
                        <dd>
                            <a href="/user/userhome.do"><i class="layui-icon" style="margin-left: 2px; font-size: 22px;">&#xe68e;</i>我的主页</a>
                        </dd>
                        <hr style="margin: 5px 0;">
                        <dd>
                        <dd><a href="/user/logout.do"><i class="iconfont-ali icon-tuichu"></i>退出</a></dd>
                        </dd>
                    </dl>
                </li>
            </c:if>
        </ul>
    </div>
</div>

<div class="fly-home fly-panel" style="background-image: url();">
    <img
            <c:if test="${!empty user.headSculpture }">src="${user.headSculpture }" </c:if>
    <c:if test="${empty user.headSculpture }">src="/resource/img/logo.JPG"</c:if> alt="${user.userName}">
    <h1>
        ${user.userName}
        <c:if test="${user.sex==1 }"><i class="iconfont icon-nan"></i></c:if>
        <c:if test="${user.sex==0 }"><i class="iconfont icon-nv"></i></c:if>
    </h1>
    <p style="padding: 10px 0; color: #5FB878;">认证等级：${user.grade} </p>

    <p class="fly-home-info">
        <c:if test="${user.joinDate!=null }"><i
                class="iconfont icon-shijian"></i><span>${user.joinDate } 加入</span></c:if>
        <c:if test="${user.address!=null }"><i class="iconfont icon-chengshi"></i><span>来自${user.address }</span></c:if>
    </p>
    <p class="fly-home-sign">（${user.introduce }）</p>
</div>

<div class="layui-container">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md6 fly-home-jie">
            <div class="fly-panel">
                <h3 class="fly-panel-title">最近发表的帖子</h3>
                <ul class="jie-row">
                    <!-- 发表的贴子循环开始 -->
                    <c:if test="${!empty publishDateList }">
                        <c:forEach items="${publishDateList }" var="publishDateList">
                            <li>
                                <!-- <span class="fly-jing">精</span> -->
                                <a href="/essay/essaydetail.do?essayId=${publishDateList.essayId }" target="_blank"
                                   class="jie-title"> ${publishDateList.title }</a>
                                <i>${publishDateList.publishDate}</i>
                                <em class="layui-hide-xs">${publishDateList.likeNumber }赞/${publishDateList.treadNumber }踩</em>
                            </li>
                        </c:forEach>
                    </c:if>
                    <!-- 发表的贴子循环结束 -->
                    <c:if test="${empty publishDateList }">
                        <div class="fly-none" style="min-height: 50px; padding:30px 0; height:auto;"><i
                                style="font-size:14px;">没有发表任何文章</i></div>
                    </c:if>
                </ul>
            </div>
        </div>

        <div class="layui-col-md6 fly-home-da">
            <div class="fly-panel">
                <h3 class="fly-panel-title">最近的回复</h3>
                <ul class="home-jieda">
                    <c:if test="${!empty essaylist }">
                        <!-- 最近的回复循环开始 -->
                        <c:forEach items="${essaylist }" var="essaylist">
                            <li>
                                <p>
                                    <span>${essaylist.publishDate }</span>
                                    在<a href="/essay/essaydetail.do?essayId=${essaylist.essayId }"
                                        target="_blank">${essaylist.title }</a>中回复
                                </p>
                            </li>
                        </c:forEach>
                        <!-- 最近的回复循环结束 -->
                    </c:if>
                    <c:if test="${empty essaylist }">
                        <div class="fly-none" style="min-height: 50px; padding:30px 0; height:auto;">
                            <span>没有回复任何文章</span></div>
                    </c:if>
                </ul>
            </div>
        </div>
    </div>
</div>

<div class="fly-footer">
    <p>Believe 社区 2019 &copy; 千夜 出品</p>
</div>
<script type="text/javascript" src="/resource/js/common.js"></script>
<script src="/resource/layui/layui.js"></script>
<script src="/resource/js/jquery.min.js"></script>
<script src="/resource/js/userhome.js"></script>
<script>

    //检测session是否过期  或者未登录
    layui.use('layer', function () {
        $(document).ready(function () {
            var se = "${user}";
            if (se == "") {
                layer.alert('登录过期或未登录，请登录', function (index) {
                    window.location.href = "/login.html";
                    layer.close(index);
                });
            }
        });
    });
</script>
</body>
</html>
